/*
 * @Author: FengKongLi 
 * @Date: 2021-08-24 19:22:10 
 * @Last Modified by: FengKongLi
 * @Last Modified time: 2021-08-24 19:48:53
 */
// 日志管理页面
<template>
  <div>
      <!-- {{tableData}} -->
    <!-- 表单数据展示 -->
    <el-table :data="tableData" border style="width: 100%">
      <el-table-column type="index" label="序号" width="80"> </el-table-column>
      <el-table-column prop="realname" label="访问人真实姓名"></el-table-column>
      <el-table-column prop="method" label="访问方式"> </el-table-column>
      <el-table-column prop="content" label="访问路径"> </el-table-column>
      <el-table-column
        prop="logTime"
        label="访问时间时间"
        :formatter="fmtTableDateDay"
      >
      </el-table-column>
    </el-table>
     <!-- 分页 -->
    <div class="page-div">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="params.page"
        :page-sizes="[5, 10, 15, 20]"
        :page-size="params.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      >
      </el-pagination>
    </div>
  </div>
</template>

<script>
import { pageQuery } from "@/api/log";
import { fmtTableDateDay } from "@/filters/index";
export default {
  data() {
    return {
        // 时间格式
      fmtTableDateDay,
    //   表格数据
      tableData: {},
      //分页参数
      params: {
        page: 1,
        pageSize: 10,
      },
      // 总条数
      total: 0,
    };
  },
  watch: {
    // 深度监听分页参数,当多少条/页发生变化时重新请求数据
    params: {
      handler() {
        this.logData();
      },
      deep: true,
    },
  },
  created() {
    this.logData();
  },
  methods: {
    async logData() {
      let res = await pageQuery(this.params);
    //   console.log(res.data);
      this.tableData = res.data.list;
      this.total=res.data.total;
    },
    //每页显示的条数发生变化时的事件处理程序
    handleSizeChange(val) {
      this.params = {
        page: 1,
        pageSize: val,
      };
    },
    // 当前页码发生变化时的事件处理程序
    handleCurrentChange(val) {
      this.params.page = val;
    },
  },
};
</script>

<style scoped>
</style>